package com.su.ou.yang;

import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;

import java.util.PriorityQueue;

public class Test8 {
    public static void main(String[] args) {
        int[] a={1,2,3,6,8,5};
        quicksort(a, 0, a.length-1);
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }

    }
   public static void quicksort(int[] nums, int left, int right) {
    int i=left;
    int j=right;
    if(left>right){
        return;
    }

    int temp=nums[left];
    while(i!=j){
        while(nums[j]>=temp&&i<j){
            j--;
        }
        nums[i]=nums[j];
        while(nums[i]<=temp&&i<j){
            i++;
        }
        nums[j]=nums[i];


    }
    nums[i]=temp;


       quicksort(nums, left, i-1);
       quicksort(nums,i+1,right);


    }




}

